//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
   tv:[],
   bgUrl:null
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  getTvData:function(res){
    var  tvarr = [];
    var tvData = res.data.data;
    for (var i = 0; i < tvData.length; i++) {
     var temp ={
       name: tvData[i].name,
       desc:tvData[i].desc,
       picUrl:tvData[i].picUrl,
       playUrl:tvData[i].playUrl
     }
     tvarr.push(temp);
    }
    console.log(tvarr)
    this.setData({
      tv: tvarr,
      bgUrl:tvarr[0].picUrl
    })
  },
  onchange:function(e){
    var cur = e.detail.current;
    this.setData({
      bgUrl:this.data.tv[cur].picUrl
    })
  },
  onLoad: function () {
    var that = this;
    wx.request({
      url: 'http://mobile.api.hunantv.com/channel/getWPDetail',
      success:function(res){
          console.log(res.data)
          if(res.data.code==200){
            that.getTvData(res);
          }
      }
    })
  }
})
